#include "drv_bsp_fdcan.h"

/**
 * @brief FDCAN发送标准格式数据帧
 * @param hfdcan: fdcan句柄
 * @param identifier: 标准格式ID
 * @param data: 指向数据缓冲区的指针
 * @param dlc: 数据长度
 * @retval None
 */
void BSP_FDCAN_SendData(FDCAN_HandleTypeDef *hfdcan, uint32_t identifier, uint8_t *data, uint32_t dlc)
{
    FDCAN_TxHeaderTypeDef txHeader = {0};

    txHeader.Identifier = identifier;
    txHeader.IdType = FDCAN_STANDARD_ID;
    txHeader.TxFrameType = FDCAN_DATA_FRAME;
    txHeader.DataLength = dlc;
    txHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
    txHeader.BitRateSwitch = FDCAN_BRS_OFF;
    txHeader.FDFormat = FDCAN_FD_CAN;
    txHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
    txHeader.MessageMarker = 0x00;
    if (HAL_FDCAN_GetTxFifoFreeLevel(hfdcan) > 0)
    {
        HAL_FDCAN_AddMessageToTxFifoQ(hfdcan, &txHeader, data);
    }
}
